package com.kfm.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Properties;

/**
 * 创建一个QueryRunner对象
 */
public class DataSourceUtils {

    public static QueryRunner getQueryRunner() throws Exception {
        return new QueryRunner(getDataSource());
    }

    private static DataSource getDataSource() throws Exception {
        Properties prop = new Properties();
        prop.load(new FileInputStream("E:\\KFM\\kfm7\\io\\datasource.properties"));
        return DruidDataSourceFactory.createDataSource(prop);
    }

}
